package com.fastgeek.platform.db.datasource.dbtype;


import java.beans.PropertyVetoException;

import javax.sql.DataSource;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.fastgeek.platform.db.datasource.*;
public class C3p0Impl implements IDataSource {

	public DataSource loadSource(DBConfig config) {
		ComboPooledDataSource cpds=new ComboPooledDataSource(true); 
		cpds.setDataSourceName("mydatasource");
		cpds.setJdbcUrl(config.getUrl());
		try {
			cpds.setDriverClass(config.getDriver());
		} catch (PropertyVetoException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		cpds.setUser(config.getUserName());
		cpds.setPassword(config.getPassword());
//		cpds.setMaxPoolSize(Integer.valueOf(ConstantUtils.getValue("c3p0.maxPoolSize").toString()));
//		cpds.setMinPoolSize(Integer.valueOf(ConstantUtils.getValue("c3p0.minPoolSize").toString()));
//		cpds.setAcquireIncrement(Integer.valueOf(ConstantUtils.getValue("c3p0.acquireIncrement").toString()));
//		cpds.setInitialPoolSize(Integer.valueOf(ConstantUtils.getValue("c3p0.initialPoolSize").toString()));
//		cpds.setMaxIdleTime(Integer.valueOf(ConstantUtils.getValue("c3p0.maxIdleTime").toString()));
		return cpds;
	}
}
